package com.hsamgle.main;

import com.hsamgle.constant.Config;
import com.hsamgle.service.Handler;
import com.hsamgle.ui.DomainForm;

import javax.swing.*;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * @feature: TODO
 * @packge: com.hsamgle.main
 * @author: 黄鹤老板
 * @create_time: 2019/7/6 13:24
 * @company: 江南皮革厂
 */
public class Main {

    public static void main(String[] args) {
        DomainForm form = new DomainForm();
        Handler.init(form);
        JFrame frame = new JFrame("内网穿透工具");
        frame.setResizable(false);
        frame.setLocationRelativeTo(null);
        frame.setContentPane(form.getPanel());
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.pack();
        frame.setVisible(true);

        // 在子线程内定时去执行同步
        ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
        executor.scheduleAtFixedRate(new Handler(), Config.SYNC_DELAY,Config.SYNC_PERIOD, TimeUnit.SECONDS);
    }

}
